/*
 *  sparsematrixumf.h
 *  EPPI-0.0
 *
 *  Created by Juan Carlos García Orden on 07/07/2010.
 *
 */
#ifndef _sparsematrixumf_h_
#define _sparsematrixumf_h_

#include <iostream>
#include <vector>
#include "commonutil.h"
#include "sparsematrix.h"
#include "umfpack.h"

using namespace std;
typedef size_t size_type;

class sparseMatrixUMF : public sparseMatrix
{
public:
	void *Symbolic,*Numeric;
	vector<double> b_out;
//Arma	rowvec b_outA;
	RowVectorXd b_outAE;
	VectorXd b_outAEV;
	vector<double> b_aux;
//Arma	rowvec vaux;
	RowVectorXd vauxE;
	
	/*	Data members from the base class sparseMatrix
	 int n;
	 int* ia;
	 int* ja;
	 double* values;
	 int nnz;
	 int nrhs;	 
	 */	
	
public:
	sparseMatrixUMF();
	sparseMatrixUMF(int, int);
	~sparseMatrixUMF();
	
	/** Virtual functions from base */
	void initMatrices(void);
	void initVectors(int);
	void factorize(int);
	void subsSolve(vector<double>&);
//Arma	void subsSolve(rowvec &);
	void subsSolve(RowVectorXd &);
	void subsSolve(VectorXd &);
	void subsSolveTrans(vector<vector<double> >&);
//	void subsSolveTrans(double*);
//Arma	void subsSolveTrans(mat &);
	void subsSolveTrans(MatrixXd &);
	void copyMatrix(sparseMatrix*);
	
	/** Local functions */

	/** Friend functions */
	friend void printSTLVector(vector<double>& v);
	friend double lTwoNormSq(const vector<double>& v1);
};
#endif
